import axiosInstance from '../utils/request.js'

// import { currentUser } from '@/store/currentUser.js'
// import { setCurrentUserInfo, currentUserToken, currentUSerTokenName } from '@/utils/auth.js'
import { setToken } from '@/utils/auth.js'
var assert = require('assert')
export const userApi = {
    login(userId, userName) {
        return axiosInstance.get('/user/login', {
            params: {
                jobNumber: userId,
                teacherName: userName
            }
        }).then(response => {
          
            setToken(response.data)
            return response.data

        })
    },
    register(userId, userName, userCollege, userPhone, userEmail) {
        return axiosInstance.post('/user/register', {
            'name': userName,
            'jobNumber': userId,
            'college': userCollege,
            'phone': userPhone,
            'email': userEmail
        })
    },
    logout() {
        return axiosInstance.get('/user/logout');
    },
    getUserInfos() {
        return axiosInstance.get('/user');
    },
    getLoginInfo() {
        return axiosInstance.get('/user/login/info')
    },
    // put post 就直接做为第二参数
    updateUser(user) {
        return axiosInstance.put('/user', user)
        
    },
    addUser(user) {
        return axiosInstance.post('/user',user)
        
    },
    // delete 的传参需要data
    deleteUser(user) {
        return axiosInstance.delete('user', {
            data:{...user}
        })
        
    }
}
